// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require(CONFIG.BasePath + "js/enterprise/base");
	var router = require("../hash/pageRouter");
	var constant = require("constant");
	var databind = require("databind");
	var dialog = require("dialog");
	var css_asd = require("./myLoanDetail.css");
	var tools = require("tools");
	var loanNoticeId;
	
	var init = function(page) {
		loanNoticeId = page.params.loanNoticeId;
		inquireLoanNoticeDetail();
		router.init();
		initEvent();
	};

	var initEvent = function() {
		if (base.getData("sid") == null) {
			location.href = "../login/login.html";
		};
	};

	var inquireLoanNoticeDetail = function() {
		tools.loadList("inquireLoanNoticeDetail.json", $("#myLoanDetailBody"), $("#myLoanDetailTpl"), {loanNoticeId: loanNoticeId}, function() {
			$.each($("#myLoanDetail .fileUuids input").val(), function() {
				if ($.trim(this) == "") {
					return true;
				}
				var str = '<a target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid='+ this +'">'+ tools.inquireFile(this) +'</a>'
				$("#myLoanDetail .fileUuids").append(str);
			});
			
			$("#myLoanDetail .detail").unbind("click").click(function() {
				router.route("account/accountTallyDetail.html?inventoryId=" + $(this).parents("tr").attr("inventoryId"));
			});
		});
	};

	return {
		init: init
	};
});